<template>
  <div id="main">
    <div class="header">
      <div class="close" @click="onclear"><Icons name="guanbi1" /></div>
    </div>
    <div class="body">
      <h1>新版本：海草V{{$Win.getParameter().version}}</h1>
      <h3>发布时间：{{$Win.getParameter().time}}</h3>
      <dl v-if="$Win.getParameter().addfun.length > 0">
        <dt>添加功能</dt>
        <dd v-for="(item, index) in $Win.getParameter().addfun" :ket="index">{{item}}</dd>
      </dl>
      <dl v-if="$Win.getParameter().debug.length > 0">
        <dt>修复功能</dt>
        <dd v-for="(item, index) in $Win.getParameter().debug" :ket="index">{{item}}</dd>
      </dl>
      <div class="button">
          <button @click="onclear" class="clear">取消更新</button>
          <button @click="onupdata"  class="updata">立即更新</button>
      </div>
    </div>
  </div>
</template>
<script>
import os from 'os'
export default {
  data: () => {
    return {
      msg: 'hahhahaha',
      arch: os.arch()
    }
  },
  components: {
  },
  watch: {
  },
  created () {
    let data = this.$Win.getParameter()
    console.log(data) // {id: 1}
  },
  methods: {
    onclear () {
      this.$Win.closeWin()
    },
    onupdata () {
      alert('已在后台开始下载安装包，下载完成会弹出安装提示！')
      let url
      if (this.arch === 'ia32') {
        url = 'https://node3.shangning.site/getOssFile?objname=' + this.$Win.getParameter().files.ia32
      } else {
        url = 'https://node3.shangning.site/getOssFile?objname=' + this.$Win.getParameter().files.x64
      }
      this.$electron.ipcRenderer.send('download_install1', {
        url: url,
        dir: require('path').join(this.$electron.remote.app.getPath('userData'), 'download')
      })
      this.$Win.closeWin()
    }
  }
}
</script>
<style lang="less" scoped>
@import './style.less';
</style>
